<template>
  <el-dialog :title="deviceTitle" :visible.sync="visible" :fullscreen="true" :close-on-click-modal="false"
    :close-on-press-escape="false" append-to-body>
    <div>
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="120px">
        <el-form-item label="序列号" prop="deviceSn">
          <el-input v-model="queryParams.deviceSn" placeholder="请输入序列号" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="mac" prop="deviceMac">
          <el-input v-model="queryParams.deviceMac" placeholder="请输入mac" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="deviceList">
        <el-table-column label="id" align="center" prop="id" />
        <el-table-column label="设备序列号" align="center" prop="deviceSn" />
        <el-table-column label="设备mac" align="center" prop="deviceMac" />
        <el-table-column label="绑定IP" align="center" prop="bindIp" />
        <el-table-column label="最后登录ip" align="center" prop="lastLoginIp" />
        <el-table-column label="最后操作日期" align="center" prop="preLineTime" />
      </el-table>
      <pagination v-show="deviceTotal>0" :total="deviceTotal" :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize" @pagination="getDeviceList" />

    </div>
  </el-dialog>
</template>

<script>
  import {
    listDevice
  } from "@/api/bus_web/school/device";

  export default {
    name: "School_device_report",
    components: {

    },
    data() {
      return {
        // 遮罩层
        loading: true,
        deviceTitle: '',
        // 显示搜索条件
        showSearch: true,
        visible: false,
        // 总条数
        deviceTotal: 0,
        deviceList: [],
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          deviceSn: null,
          deviceMac: null,
          schoolIdArray: []
        }
      };
    },
    methods: {
      init(row) {
        this.deviceTitle = '[' + row.schoolName + ']设备列表'
        this.resetForm("queryForm")
        this.queryParams.schoolIdArray.push(row.id)
        this.visible = true
        this.getDeviceList()
      },
      getDeviceList() {
        this.loading = true;
        listDevice(this.queryParams).then(response => {
          this.deviceList = response.rows;
          this.deviceTotal = response.total;
          this.loading = false;
        });
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getDeviceList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
    }
  };
</script>
